
	var afterLoad = null;

	//override xtree function
	function _startLoadXmlTree(sSrc, jsNode) {
		if (jsNode.loading || jsNode.loaded)
			return;
		jsNode.loading = true;
		var xmlHttp = XmlHttp.create();
		xmlHttp.open("GET", sSrc, true);	// async
		xmlHttp.onreadystatechange = function () {
			if (xmlHttp.readyState == 4) {
				var oXmlDoc = xmlHttp.responseXML;
				var root = oXmlDoc.documentElement;
				if(root.tagName=='error'){
					alert(root.getAttribute("message"));
					return;
				}
				_xmlFileLoaded(oXmlDoc, jsNode);
				
				if(!jsNode.folder){//目录图标
					jsNode.folder = true;
					jsNode.expand();	
				}
				if(afterLoad){
					afterLoad(jsNode);
				}
			}
		};
		// call in new thread to allow ui to update
		window.setTimeout(function () {
			xmlHttp.send(null);
		}, 10);
	}

	var xWebkitPath = "../../widgets/xloadtree/";
	var accessPath = "../../fileInfo/access";
	var userInfoPath = "../../fileInfo/userinfo";
	var rootPath = '/';
	
	//变量
	var popupMenuTreeNodeId = null;
	
	function getFullPath(node) {
	    var curNode = node;
	    var path = '';
	    while (curNode && !curNode.tree) {
	    	 path = '/' + curNode.text + path;
	        if (curNode.text == rootPath) {
	           break;
	        }
	        curNode = curNode.parentNode;
	    };
	    path = path.replace('///','/');
	    path = path.replace('//','/');
	    return path;
	}
	
	function getNode(nodeId){
		var node = webFXTreeHandler.all[webFXTreeHandler.idPrefix+nodeId];
		return node;
	}	

	function getChildNode(parent, childText){
		var children = parent.childNodes;
		for(var i=0;i<children.length;i++){
			var node = children[i];
			if(node.text == childText){
				return node;
			}
		}
		return null;
	}
	
	function menuAction() {
	    var node = tree.getSelected();
	    alert(getFullPath(node));
	}

	function setItemMenu(){
		Browser.disableContextMenu(false);
		
		function closePopupMenu(e){
			if(!e)e = window.event;
			var src = e.target||e.srcElement;
			if(src.tagName=='A'){
				return;
			}
			$E('popupMenu').style.display='none';
			popupMenuTreeNodeId = null;
		}
		
		function showPopupMenu(e, itemId, actions){
			var menu = $E('popupMenu');
			var menuItems = DomUtil.getChildren(menu);
			
			if(actions){
				for(var i=0;i<menuItems.length;i++){
					menuItem = menuItems[i];
					menuItem.style.display = actions.indexOf(''+i)!=-1?'':'none';
				}
			}
			
			Dialog.popupDiv('popupMenu', e);
			popupMenuTreeNodeId = itemId;
			EventUtil.stopPropagation(e);
		}
		
		EventUtil.addEvent('treeContainer', 'mouseup', function(e){
			if(!e)e = window.event;
			var src = e.target||e.srcElement;
			if(e.button==2){
				var id = src.id+'';
				if(id.startsWith('webfx-tree-object-') && (StringUtil.endsWith(id, '-anchor')||StringUtil.endsWith(id, '-icon'))){
					var s = id.substr(18).split('-');
					var itemId = s[0];
					showPopupMenu(e, itemId, '01');
					return;
				}
			}
			closePopupMenu(e);
		});
		
		EventUtil.register('keydown', function(e){
			if(e.keyCode==27){
				closePopupMenu(e);
			}
		}, 'popupMenu_kd_close');
		EventUtil.register('mouseup', function(e){
			closePopupMenu(e);
		}, 'popupMenu_mu_close');
		EventUtil.register('mousedown', function(e){
			closePopupMenu(e);
		}, 'popupMenu_md_close');
	}
	
	var tree;
	
	function initTree(){
	    webFXTreeConfig.rootIcon = xWebkitPath+"images/xp/folder.png";
	    webFXTreeConfig.openRootIcon = xWebkitPath+"images/xp/openfolder.png";
	    webFXTreeConfig.folderIcon = xWebkitPath+"images/xp/folder.png";
	    webFXTreeConfig.openFolderIcon = xWebkitPath+"images/xp/openfolder.png";
	    webFXTreeConfig.fileIcon = xWebkitPath+"images/xp/file.png";
	    webFXTreeConfig.lMinusIcon = xWebkitPath+"images/xp/Lminus.png";
	    webFXTreeConfig.lPlusIcon = xWebkitPath+"images/xp/Lplus.png";
	    webFXTreeConfig.tMinusIcon = xWebkitPath+"images/xp/Tminus.png";
	    webFXTreeConfig.tPlusIcon = xWebkitPath+"images/xp/Tplus.png";
	    webFXTreeConfig.iIcon = xWebkitPath+"images/xp/I.png";
	    webFXTreeConfig.lIcon = xWebkitPath+"images/xp/L.png";
	    webFXTreeConfig.tIcon = xWebkitPath+"images/xp/T.png";
	    webFXTreeConfig.blankIcon = xWebkitPath+"images/blank.png";
	    webFXTreeConfig.usePersistence = false;
	
	    var url = accessPath+rootPath+"?method=getChildren";
	    tree = new WebFXTree("zkmanager");
	    tree.add(new WebFXLoadTreeItem(rootPath, url, "javascript:menuAction()"));
	
	    document.getElementById('treeContainer').innerHTML = tree;
	}

